<?php 
include('./fun.php');
$conn=my_sql($cfg);
$re=adm_login();
if($re['err']=='no_login'){die('<script>no_login()</script>');}
if($re['err']!='ok'){die('<hh><b>'.$re['err'].'</b></hh>');}
$adm=$re['adm'];
if($adm['power']!='adm'){err('抱歉，您没有查看的权限');}

$sql='select * from '.$cfg['e'].'print ';

$l=db($sql);
?>
<style>

</style>
<hh><b>打印机管理</b></hh>
<help style="margin-top:0">请设置打印机，用户下单后默认打印小票,订单管理页面可手动打印小票<br>
</help>

<mm>
<index>
<a class="m b" onclick="edit($(this))" i="0" c="<?php echo $c?>">添加打印机</a>
</index>

<?php 
if($l){
echo '<table>';
th(['打印机厂家','打印机名称','所属商户','打印机终端号','打印机密匙','操作']);
foreach($l as $v){
echo '<tr>';
echo '<td>'.$v['c'].'</td>';
echo '<td style="width:30%">'.$v['name'].'</td>';
echo '<td style="width:30%">'.$v['shop_id'].'</td>';
echo '<td>'.$v['appid'].'</td>';
echo '<td>'.$v['appkey'].'</td>';
echo '<td>
<a onclick="edit($(this))" i="'.$v['id'].'" c="'.$v['c'].'">修改</a>
</td>';
echo '</tr>';
}
echo '</table>';
}else{no_data();}
?>
</mm>

<script>

function edit(o){
var id=o.attr('i');if(!id){id=0;}
var c=o.attr('c');
right({title:'打印机编辑',url:'printer_edit.php?id='+id,width:'500px'})
}

</script>